﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartSpace.Core;
using SmartSpace.Data.AutoInput;

namespace SmartSpace.Data
{
    public static class Convertors
    {
        private static Dictionary<string, IDataConvertor> s_convertors = new Dictionary<string, IDataConvertor>();

        static Convertors()
        {
            s_convertors.Add("identity", new IdentityConvertor());
            s_convertors.Add("date", new DateConvertor());
            s_convertors.Add("text", new DefaultConvertor());
            s_convertors.Add("textarea", new DefaultConvertor());
            s_convertors.Add("time", new DefaultConvertor());
            s_convertors.Add("create.user", new CreateUserConvertor());
            s_convertors.Add("create.date", new CreateDateTimeConvertor());
        }

        public static IDataConvertor Get(string type)
        {
            if (s_convertors.ContainsKey(type))
            {
                return s_convertors[type];
            }
            else
            {
                return new DefaultConvertor();
            }
        }
    }
}
